<template>
	<view>
		<view class="prooFread">
			<text>手机号{{' '}}{{phone}}</text>
			<view class="skyCheak">
				<text>验证码</text><input type="number" placeholder="请输入验证码" v-model="prooNumber" maxlength="6" />
				<view class="textRecapt" @click="recaptCha">
					<text class="textRecapt">重新获取验证码</text>
				</view>

			</view>

			<view class="suerpFread">
				<view @click="cancel"><text>取消</text></view>
				<view @click="sureProo">
					<text>确定</text>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				phone: '',
				androidIos: '',
				prooNumber: ''
			}
		},
		onLoad() {
			this.androidIos = getApp().globalData.androidIos
		},
		computed: {
			...mapState(['userInfo'])
		},
		onShow(e) {
			this.phone = this.userInfo.phone || '';
		},
		methods: {
			cancel() {
				uni.navigateBack({
					delta: 1
				})
			},
			sureProo() {
				if (this.prooNumber == '') {
					uni.showToast({
						title: '请输入验证码',
						icon: 'none'
					});
					return;
				}
				let data = {
					appId: this.androidIos,
					phone: this.phone,
					code: this.prooNumber
				}
				this.$httpNew.post('authApi/user/UpdateUserPhoneForCheckOld', data).then(res => {
					console.log(res);
					this.checkCode = res
					if (res != '') {
						uni.navigateTo({
							url: './user_changephone?checkCode=' + this.checkCode
						})
					}
				})
			},
			recaptCha() {
				this.$httpNew.get('authApi/auth/GetVerificationCodeByOldPhone', {
					phone: this.phone,
					appId: this.androidIos,
				}).then(res => {
					if (res == null) {
						uni.showToast({
							title: '发送成功',
							icon: 'none'
						});
						return;

					}

				})

			}
		}
	}
</script>
<style>
	page {
		background-color: #fff;
	}
</style>

<style lang="less">
	.prooFread {
		width: 100%;
		margin-top: 40%;

		>text {
			margin-left: 4%;
		}


		.skyCheak {
			width: 100%;
			height: 100rpx;
			margin: auto;
			margin-top: 5%;
			display: flex;
			align-items: center;
			justify-content: space-around;
			background-color: #f5f5f5;

			input {
				background-color: #f5f5f5;
				text-indent: 20rpx;
			}
		}

		.suerpFread {
			width: 95%;
			margin: auto;
			margin-top: 10%;
			display: flex;
			justify-content: space-around;

			>view {
				width: 250rpx;
				height: 70rpx;
				border-radius: 70rpx;
				text-align: center;
				line-height: 70rpx;
				border: 1px solid #f5f5f5;
			}

			>view:nth-child(1) {
				background-color: #f5f5f5;
			}

			>view:nth-child(2) {
				color: #b5001e;
			}
		}

		.textRecapt {
			width: 220rpx;
			height: 60rpx;
			border-radius: 60rpx;
			line-height: 60rpx;
			background-color: #b5001e;
			color: #fff;
			text-align: center;
			font-size: 14rpx;
		}

	}
</style>
